package com.mixsmart.commonweb.upload.classify;

import org.springframework.stereotype.Component;

import com.mixsmart.commonweb.upload.ClassifyModel;
import com.mixsmart.commonweb.upload.UploadClassifyUtils;
import com.mixsmart.utils.StringUtils;

/**
 * 按文件类型归类
 * @author lmq
 * @version 1.0
 * @since JDK1.6以上
 * <br />
 * 2016年7月22日
 */
@Component
public class FileTypeClassify extends AbstractUploadClassify {

	@Override
	public String getName() {
		return "file_type";
	}

	@Override
	protected String classify(ClassifyModel classifyModel) {
		if(null != classifyModel && 
				StringUtils.isNotEmpty(classifyModel.getFileName())) {
			String fileSuffix = StringUtils.getFileSuffix(classifyModel.getFileName());
			if(StringUtils.isNotEmpty(fileSuffix)) {
				return UploadClassifyUtils.getClassifyDir(fileSuffix);
			}
		}
		return null;
	}
}
